from django.conf.urls import url
from django.contrib import admin

from . import viewset_view
from . import views
from . import apiviews
from . import genericapiview
from . import mixinview
from . import childmixin
urlpatterns = [
    url(r'^books_drf/$', views.BooksDRF.as_view()),
    url(r'^books_drf/(?P<pk>\d+)/$', views.BookDRF.as_view()),
    #APIview--接受数据 和响应数据的时候,包含对 数据的解析,
    url(r'^books_drf_api/$', apiviews.BooksDRF.as_view()),
    url(r'^books_drf_api/(?P<pk>\d+)/$', apiviews.BookDRF.as_view()),
    #genericapiview,指定查询基,序列化对象,调用查询集,调用序列化方法,继承APIView视图的功能快,
    url(r'^books_drf_generic/$', genericapiview.BooksDRF.as_view()),
    url(r'^books_drf_generic/(?P<pk>\d+)/$', genericapiview.BookDRF.as_view()),
    #mixinview 多个数据的继承查询,和保存
    url(r'^books_drf_mixin/$', mixinview.BooksDRF.as_view()),
    url(r'^books_drf_mixin/(?P<pk>\d+)/$', mixinview.BookDRF.as_view()),
    #子类的多继承儿子继承多数据的查询,和保存,另一儿子单一数据的查询,修改,删除
    url(r'^books_drf_child/$', childmixin.BooksDRF.as_view()),
    url(r'^books_drf_child/(?P<pk>\d+)/$', childmixin.BookDRF.as_view()),
    # GenericViewSet使用
    url(r'^books_drf_viewset/$', viewset_view.BooksDRF.as_view({'get': 'list','post':'create'})),
    url(r'^books_drf_viewset/(?P<pk>\d+)/$', viewset_view.BookDRFModelViewsetBookDRF.as_view({'put':'update'})),
    url(r'^books_drf_viewset/lastdata/$', viewset_view.BookDRFModelViewsetBookDRF.as_view({'get':'lastdata'})),
    # ModelViewSet使用
    url(r'^books_drf_ModelViewSet/$', viewset_view.BookDRFModelViewset.as_view({'get': 'list','post':'create'})),
    url(r'^books_drf_ModelViewSet/(?P<pk>\d+)/$', viewset_view.BookDRFModelViewset.as_view({'put':'update','get':'retrieve'})),
]
#逻辑:在指定路由映射后.不需要,再书写def get def post pust delete ,直接由以视图函数的形式进行调用
# 当前端发送请求后,将请求方式映射成,调用函数的形式,调用分类封装好的方法